package com.playball.lottery.frm.buyhall;

import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Random;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;

import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.text.Html;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.playball.lottery.R;
//import com.playball.lottery.customview.ApplicationBall;
import com.playball.lottery.ApplicationData;
import com.playball.lottery.JddMainActivity;
import com.playball.lottery.base.BaseActivity;
import com.playball.lottery.customview.BallDTO;
import com.playball.lottery.customview.SsqxhDialog;
import com.playball.lottery.frm.help.CaiPiaoHelp;
import com.playball.lottery.frm.kjinfo.KjinfoListByType;
import com.playball.lottery.frm.yhzx.BetRecordActivity;
import com.playball.lottery.frm.yhzx.LoginActivity;
import com.playball.lottery.frm.yhzx.ZhRecordActivity;
import com.playball.lottery.nt.GetRequestParams;
import com.playball.lottery.util.ConvertJsonToList;
import com.playball.lottery.util.DateUtil;
import com.playball.lottery.util.DefConstants;
import com.playball.lottery.util.DynArrayInt;
import com.playball.lottery.util.FactoryNum;
import com.playball.lottery.util.SensorListener;
import com.playball.lottery.util.SoundManage;
import com.playball.lottery.util.SysApplication;


public class SsqxhActivity extends BaseActivity implements Serializable, DefConstants {
	private static final long serialVersionUID = 1L;
	Button imButton01, imButton02, imButton03, imButton04, imButton05, imButton06, imButton07, imButton08, imButton09,
			imButton10, imButton11, imButton12, imButton13, imButton14, imButton15, imButton16, imButton17, imButton18,
			imButton19, imButton20, imButton21, imButton22, imButton23, imButton24, imButton25, imButton26, imButton27,
			imButton28, imButton29, imButton30, imButton31, imButton32, imButton33;
	Button imButton34, imButton35, imButton36, imButton37, imButton38, imButton39, imButton40, imButton41, imButton42,
			imButton43, imButton44, imButton45, imButton46, imButton47, imButton48, imButton49;
	// Button buy_ssqxh_Button01;// 机选红球
	// Button buy_ssqxh_Button02;// 机选蓝球
	// LinearLayout buy_ssqxh_Button03;// 清空选择
	// LinearLayout buy_ssqxh_Button04;// 机选红球+蓝球
	Button buy_ssqxh_Buttondel, buy_ssqxh_Buttonrandom;
	Button buy_ssqxh_Button05;// 确认选择
	TextView buy_ssqxh_TextView01;// 期号
	TextView buy_ssqxh_TextView02;// 截至日期
	TextView buy_ssqxh_TextView03;// 注数
	TextView buy_ssqxh_TextView04;// 金额
	private int lotID;
	private String issueID;
	private String issueName;
	private long endTime; // 剩余时间
	private String strssqEndTime;// 截止时间
	private int allMoney;
	View view;
	Handler handler = new Handler();
	private SensorListener sensor;
	private PopupWindow m_popupWindow;
	private SsqxhDialog ssq_dialog; // 自定义Dialog
	public int[] red_random;// 所选的红球
	public int[] blue_random;// 所选的红球
	private DynArrayInt red_dintInt;
	private DynArrayInt blue_dintInt;
	/** 摇一摇机选一注视图 */
	private LinearLayout buy_ssq_llfoot0;
	/** 注数金额 */
	private RelativeLayout buy_ssq_rlfoot1;
	/** 点击此处可以弹出下拉10期开奖 */
	private LinearLayout buy_ssqxh_llxiala;
	/** 下拉10期开奖详情 */
	private LinearLayout buy_ssqxh_ll10kjdetail;
	/** 下拉10期开奖详情 */
	private List<Map<String, Object>> kjData;
	/** 判断是否从选号列表过来 */
	private int position;
	private Boolean ifbacklist;
	/** 判断是否从推送通知过来 */
	private Boolean ifPush;
	private ImageView history_record;// 历史记录
	private TextView guize_text;
	private Button jx_5_btn;
	
	private LinearLayout buy_ssqxh_Button03,buy_ssqxh_Button04;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.buy_ssqxh);
		SysApplication.getInstance().addActivity(this);

		Intent intent = getIntent();
		lotID = LOT_ID_SSQ;
		issueID = intent.getStringExtra("IssueID");
		issueName = intent.getStringExtra("IssueName");
		endTime = intent.getLongExtra("EndTime", 0);
		strssqEndTime = intent.getStringExtra("strssqEndTime");
		position = intent.getIntExtra("position", -1);
		ifbacklist = intent.getBooleanExtra("ifbacklist", false);
		ifPush = intent.getBooleanExtra("ifPush", false);
		initView();
		buy_ssqxh_TextView01.setText(issueName);
		KJAsyncLoader task = new KJAsyncLoader();
		task.execute(LOT_ID_SSQ + "", "301");

		int isfromkaiJiang = intent.getIntExtra("isfromkaiJiang", 0);
		if (isfromkaiJiang == 1 || !ifbacklist) {
			Random(6, 1);
		}

		// 机选红球
		// buy_ssqxh_Button01.setOnClickListener(new View.OnClickListener() {
		// @Override
		// public void onClick(View v) {
		// // 随机前先把所有的红球初始化
		// RedBallInit();
		// // 清空之前red_dintInt里边已经选过的号码
		// red_dintInt = new DynArrayInt();
		// red_dintInt.removeAll();
		// // 开始随机红球号码
		// int red_random[] = RandomGenData(1, 33, 6, "red");
		// // 追加数组到red_dintInt中
		// red_dintInt.addInt(red_random);
		// // 计算
		// FactoryResult();
		// }
		// });
		// 机选蓝球
		// buy_ssqxh_Button02.setOnClickListener(new View.OnClickListener() {
		// @Override
		// public void onClick(View v) {
		// // TODO Auto-generated method stub
		// // 随机前先把所有的蓝球初始化
		// BlueBallInit();
		// // 清空之前red_dintInt里边已经选过的号码
		// blue_dintInt = new DynArrayInt();
		// blue_dintInt.removeAll();
		// // 开始随机红球号码
		// int blue_random[] = RandomGenData(1, 16, 1, "blue");
		// // 追加数组到red_dintInt中
		// blue_dintInt.addInt(blue_random);
		// // 计算
		// FactoryResult();
		// }
		// });
		// 下拉10期开奖
		buy_ssqxh_llxiala.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				doKaiJiang();
			}
		});
		history_record.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				doKaiJiang();
			}
		});

		buy_ssqxh_ll10kjdetail.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (buy_ssqxh_ll10kjdetail.getVisibility() == View.VISIBLE) {
					buy_ssqxh_ll10kjdetail.setVisibility(View.GONE);
				}
			}
		});
		// 清空选择
		buy_ssqxh_Buttondel .setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (red_dintInt.getSize() != 0 || blue_dintInt.getSize() != 0) {
					// MyDialog.Builder dialog = new
					// MyDialog.Builder(SsqxhActivity.this);
					// dialog.setTitle("清空号码提示");
					// dialog.setMessage("清空后您已选择的号码列表将会清空，确认继续?");
					// dialog.setPositiveButton("确定", new
					// DialogInterface.OnClickListener() {
					// @Override
					// public void onClick(DialogInterface dialog, int which) {
					RedBallInit();
					BlueBallInit();
					buy_ssqxh_TextView03.setText("0");
					buy_ssqxh_TextView04.setText("0");
					buy_ssq_llfoot0.setVisibility(View.VISIBLE);
					buy_ssq_rlfoot1.setVisibility(View.GONE);
					// dialog.cancel();
					// }
					// });
					// dialog.setNegativeButton("取消", new
					// DialogInterface.OnClickListener() {
					// @Override
					// public void onClick(DialogInterface dialog, int which) {
					// dialog.cancel();
					// }
					// }).create().show();
				} else {
					Toast.makeText(SsqxhActivity.this, R.string.number_did_not_choose, Toast.LENGTH_SHORT).show();
				}
			}
		});
		// 机选红球+蓝球
		buy_ssqxh_Buttonrandom.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Random(6, 1);
			}
		});
		// 晃动机选号码
		sensor = new SensorListener(this);
		sensor.setOnSensorListener(new SensorListener.OnSensorListener() {
			@Override
			public void onShake() {
				// TODO Auto-generated method stub
				SoundManage.OnVibator(SsqxhActivity.this, 500);
				Random(6, 1);
				// SoundManage.OnPlaySound(SsqxhActivity.this, "audio.mp3");
			}
		});

		// 确认选择，跳转至SsqxhlbActivity.class
		buy_ssqxh_Button05.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				
				goXhlbSubmit();
				
				
			}
		});

		jx_5_btn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {

				for (int i = 0; i < 5; i++) {
					red_dintInt = new DynArrayInt();
					blue_dintInt = new DynArrayInt();
					red_random = RandomGenData(1, 33, 6, "red");
					blue_random = RandomGenData(1, 16, 1, "blue");
					red_dintInt.addInt(red_random);
					blue_dintInt.addInt(blue_random);
					String red_ball = red_dintInt.getAllIntToString(red_dintInt.getAllInt());
					red_ball = red_ball.substring(0, red_ball.length() - 1);
					String blue_ball = blue_dintInt.getAllIntToString(blue_dintInt.getAllInt());
					blue_ball = blue_ball.substring(0, blue_ball.length() - 1);
					BallDTO ssqdto = new BallDTO();
					ssqdto.setSsq_ball(red_ball + "-" + blue_ball + "-" + 2);
					ApplicationData.getInstance().getList_ssqdto().add(ssqdto);
				}
				allMoney = (int) (10 + 1.0e-6) * 2;

				ApplicationData.getInstance().setAll_ssqmoney(
						ApplicationData.getInstance().getAll_ssqmoney() + allMoney);

				Intent intent = new Intent();
				intent.putExtra("list_ssqdto", ApplicationData.getInstance().getList_ssqdto());
				intent.putExtra("AllMoney", ApplicationData.getInstance().getAll_ssqmoney());
				intent.putExtra("LotID", lotID);
				intent.putExtra("IssueID", issueID);
				intent.putExtra("IssueName", issueName);
				intent.setClass(SsqxhActivity.this, SsqxhlbActivity.class);
				SsqxhActivity.this.startActivityForResult(intent, REQ_CODE_BUYMAIN);// (intent);
				finish();
			}
		});
		handler.postDelayed(runnable, 1000);

	}

	/**
	 * 提交选号
	 */
	protected void goXhlbSubmit() {
		// TODO Auto-generated method stub

		if (checkUserLogin()) {
			
			if (issueName == null || issueName.equals("")) {
				Toast.makeText(SsqxhActivity.this, R.string.is_retrieving_period_time, Toast.LENGTH_SHORT)
						.show();
				return;
			}
			if (red_dintInt.getAllInt().length > 5 && blue_dintInt.getAllInt().length > 0) {
				if (red_dintInt.getAllInt().length < 21) {
					// 在这个Activity每选中一注球，所有号码全部存储到xxx_dintInt int[]数组中
					String red_ball = red_dintInt.getAllIntToString(red_dintInt.getAllInt());
					red_ball = red_ball.substring(0, red_ball.length() - 1);
					String blue_ball = blue_dintInt.getAllIntToString(blue_dintInt.getAllInt());
					blue_ball = blue_ball.substring(0, blue_ball.length() - 1);
					String ssq_money = buy_ssqxh_TextView04.getText().toString();

					// 实例化一个新的BallDTO放入到全局变量ApplicationBall中的List_ssq里
					BallDTO ssqdto = new BallDTO();
					ssqdto.setSsq_ball(red_ball + "-" + blue_ball + "-" + ssq_money);

					// 将我们放到进程中的全局变量拿出来，看是不是我们曾经设置的值
					Log.i("application_ssq", "InitLabel:application_ssq_sel:"
							+ ApplicationData.getInstance().getList_ssqdto().size());

					// 新选的号码，追加在ApplicationBall全局变量list_ssqdto里
					if (position != -1) {
						ApplicationData.getInstance().getList_ssqdto().remove(position);
						ApplicationData.getInstance().getList_ssqdto().add(position, ssqdto);
						;
					} else {
						ApplicationData.getInstance().getList_ssqdto().add(ssqdto);
					}
					ApplicationData.getInstance().setAll_ssqmoney(
							ApplicationData.getInstance().getAll_ssqmoney() + allMoney);

					Intent intent = new Intent();
					intent.putExtra("list_ssqdto", ApplicationData.getInstance().getList_ssqdto());
					intent.putExtra("AllMoney", ApplicationData.getInstance().getAll_ssqmoney());
					intent.putExtra("LotID", lotID);
					intent.putExtra("IssueID", issueID);
					intent.putExtra("IssueName", issueName);
					intent.setClass(SsqxhActivity.this, SsqxhlbActivity.class);
					SsqxhActivity.this.startActivityForResult(intent, REQ_CODE_BUYMAIN);// (intent);
					finish();
				} else {
					Toast.makeText(SsqxhActivity.this, R.string.optional_twenty_most_red_balls,
							Toast.LENGTH_SHORT).show();
				}

			} else {
				Toast.makeText(SsqxhActivity.this, R.string.select_at_least_one_number, Toast.LENGTH_SHORT)
						.show();
			}
			
		} else {

			Intent intent = new Intent(SsqxhActivity.this, LoginActivity.class);
			startActivityForResult(intent, REQ_CODE_BUY_LOGIN);
			
		}
	
	}

	// 倒计时
	Runnable runnable = new Runnable() {
		@Override
		public void run() {
			getCountDown(endTime--);
			handler.postDelayed(this, 1000);
		}
	};

	// View初始化
	public void initView() {
		// TitleBar标题栏
		TitleBar();
		buy_ssq_llfoot0 = (LinearLayout) findViewById(R.id.buy_ssq_llfoot0);
		buy_ssq_rlfoot1 = (RelativeLayout) findViewById(R.id.buy_ssq_rlfoot1);
		buy_ssqxh_llxiala = (LinearLayout) findViewById(R.id.buy_ssqxh_llxiala);
		buy_ssqxh_ll10kjdetail = (LinearLayout) findViewById(R.id.buy_ssqxh_ll10kjdetail);
		// 初始化Button
		// buy_ssqxh_Button01 = (Button) findViewById(R.id.buy_ssqxh_Button01);
		// buy_ssqxh_Button02 = (Button) findViewById(R.id.buy_ssqxh_Button02);
		buy_ssqxh_Button03 = (LinearLayout) findViewById(R.id.buy_ssqxh_Button03);
		buy_ssqxh_Button04 = (LinearLayout) findViewById(R.id.buy_ssqxh_Button04);
		buy_ssqxh_Buttondel = (Button) findViewById(R.id.buy_ssqxh_Buttondel);
		buy_ssqxh_Buttonrandom = (Button) findViewById(R.id.buy_ssqxh_Buttonrandom);
		buy_ssqxh_Button05 = (Button) findViewById(R.id.buy_ssqxh_Button05);
		jx_5_btn = (Button) findViewById(R.id.jx_5_btn);
		// 初始化文本域
		buy_ssqxh_TextView01 = (TextView) findViewById(R.id.buy_ssqxh_TextView01);
		buy_ssqxh_TextView02 = (TextView) findViewById(R.id.buy_ssqxh_TextView02);
		buy_ssqxh_TextView02.setText("--------------");
		history_record = (ImageView) findViewById(R.id.history_record);
		guize_text = (TextView) findViewById(R.id.guize_text);
		guize_text.setText(Html.fromHtml("至少选<font color='#fe5052'>" + 6 + "</font>个红球   <font color='#50a6ea'>" + 1
				+ "</font>个蓝球"));
		buy_ssqxh_TextView03 = (TextView) findViewById(R.id.buy_ssqxh_TextView03);
		buy_ssqxh_TextView03.setText("0");
		buy_ssqxh_TextView04 = (TextView) findViewById(R.id.buy_ssqxh_TextView04);
		buy_ssqxh_TextView04.setText("0");

		buy_ssq_llfoot0.setVisibility(View.VISIBLE);
		buy_ssq_rlfoot1.setVisibility(View.GONE);

		// 初始化红蓝球
		RedBallInit();
		BlueBallInit();

		// huangdong();
		if (position != -1) {
			editNum();
		}

	}

	/**
	 * 开奖栏点击 事件
	 */
	protected void doKaiJiang() {
		if (kjData != null && buy_ssqxh_ll10kjdetail.getVisibility() == View.GONE) {
			buy_ssqxh_ll10kjdetail.setVisibility(View.VISIBLE);
			TextView buy_ssq_10qikj_tvqici1 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvqici1);
			TextView buy_ssq_10qikj_tvqici2 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvqici2);
			TextView buy_ssq_10qikj_tvqici3 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvqici3);
			TextView buy_ssq_10qikj_tvqici4 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvqici4);
			TextView buy_ssq_10qikj_tvqici5 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvqici5);
			TextView buy_ssq_10qikj_tvqici6 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvqici6);
			TextView buy_ssq_10qikj_tvqici7 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvqici7);
			TextView buy_ssq_10qikj_tvqici8 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvqici8);
			TextView buy_ssq_10qikj_tvqici9 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvqici9);
			TextView buy_ssq_10qikj_tvqici10 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvqici10);

			TextView buy_ssq_10qikj_tvred1 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvred1);
			TextView buy_ssq_10qikj_tvred2 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvred2);
			TextView buy_ssq_10qikj_tvred3 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvred3);
			TextView buy_ssq_10qikj_tvred4 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvred4);
			TextView buy_ssq_10qikj_tvred5 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvred5);
			TextView buy_ssq_10qikj_tvred6 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvred6);
			TextView buy_ssq_10qikj_tvred7 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvred7);
			TextView buy_ssq_10qikj_tvred8 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvred8);
			TextView buy_ssq_10qikj_tvred9 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvred9);
			TextView buy_ssq_10qikj_tvred10 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvred10);

			TextView buy_ssq_10qikj_tvblue1 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvblue1);
			TextView buy_ssq_10qikj_tvblue2 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvblue2);
			TextView buy_ssq_10qikj_tvblue3 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvblue3);
			TextView buy_ssq_10qikj_tvblue4 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvblue4);
			TextView buy_ssq_10qikj_tvblue5 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvblue5);
			TextView buy_ssq_10qikj_tvblue6 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvblue6);
			TextView buy_ssq_10qikj_tvblue7 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvblue7);
			TextView buy_ssq_10qikj_tvblue8 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvblue8);
			TextView buy_ssq_10qikj_tvblue9 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvblue9);
			TextView buy_ssq_10qikj_tvblue10 = (TextView) findViewById(R.id.buy_ssq_10qikj_tvblue10);

			if (kjData != null && kjData.size() > 0) {
				buy_ssq_10qikj_tvqici1.setText(kjData.get(0).get("Issue").toString());
				buy_ssq_10qikj_tvred1.setText(kjData.get(0).get("Ball").toString());
				if (kjData.size() > 1) {
					buy_ssq_10qikj_tvqici2.setText(kjData.get(1).get("Issue").toString());
					buy_ssq_10qikj_tvred2.setText(kjData.get(1).get("Ball").toString());
				}
				if (kjData.size() > 2) {
					buy_ssq_10qikj_tvqici3.setText(kjData.get(2).get("Issue").toString());
					buy_ssq_10qikj_tvred3.setText(kjData.get(2).get("Ball").toString());
				}
				if (kjData.size() > 3) {
					buy_ssq_10qikj_tvqici4.setText(kjData.get(3).get("Issue").toString());
					buy_ssq_10qikj_tvred4.setText(kjData.get(3).get("Ball").toString());
				}
				if (kjData.size() > 4) {
					buy_ssq_10qikj_tvqici5.setText(kjData.get(4).get("Issue").toString());
					buy_ssq_10qikj_tvred5.setText(kjData.get(4).get("Ball").toString());
				}
				if (kjData.size() > 5) {
					buy_ssq_10qikj_tvqici6.setText(kjData.get(5).get("Issue").toString());
					buy_ssq_10qikj_tvred6.setText(kjData.get(5).get("Ball").toString());
				}
				if (kjData.size() > 6) {
					buy_ssq_10qikj_tvqici7.setText(kjData.get(6).get("Issue").toString());
					buy_ssq_10qikj_tvred7.setText(kjData.get(6).get("Ball").toString());
				}
				if (kjData.size() > 7) {
					buy_ssq_10qikj_tvqici8.setText(kjData.get(7).get("Issue").toString());
					buy_ssq_10qikj_tvred8.setText(kjData.get(7).get("Ball").toString());
				}
				if (kjData.size() > 8) {
					buy_ssq_10qikj_tvqici9.setText(kjData.get(8).get("Issue").toString());
					buy_ssq_10qikj_tvred9.setText(kjData.get(8).get("Ball").toString());
				}
				if (kjData.size() > 9) {
					buy_ssq_10qikj_tvqici10.setText(kjData.get(9).get("Issue").toString());
					buy_ssq_10qikj_tvred10.setText(kjData.get(9).get("Ball").toString());
				}

				if (kjData.get(0).get("BlueBall") != null && !"".equals(kjData.get(0).get("BlueBall").toString())) {
					buy_ssq_10qikj_tvblue1.setText(kjData.get(0).get("BlueBall").toString());
					if (kjData.size() > 1) {
						buy_ssq_10qikj_tvblue2.setText(kjData.get(1).get("BlueBall").toString());
					}
					if (kjData.size() > 2) {
						buy_ssq_10qikj_tvblue3.setText(kjData.get(2).get("BlueBall").toString());
					}
					if (kjData.size() > 3) {
						buy_ssq_10qikj_tvblue4.setText(kjData.get(3).get("BlueBall").toString());
					}
					if (kjData.size() > 4) {
						buy_ssq_10qikj_tvblue5.setText(kjData.get(4).get("BlueBall").toString());
					}
					if (kjData.size() > 5) {
						buy_ssq_10qikj_tvblue6.setText(kjData.get(5).get("BlueBall").toString());
					}
					if (kjData.size() > 6) {
						buy_ssq_10qikj_tvblue7.setText(kjData.get(6).get("BlueBall").toString());
					}
					if (kjData.size() > 7) {
						buy_ssq_10qikj_tvblue8.setText(kjData.get(7).get("BlueBall").toString());
					}
					if (kjData.size() > 8) {
						buy_ssq_10qikj_tvblue9.setText(kjData.get(8).get("BlueBall").toString());
					}
					if (kjData.size() > 9) {
						buy_ssq_10qikj_tvblue10.setText(kjData.get(9).get("BlueBall").toString());
					}
				} else {
					TextView buy_10qikj_tvfh1 = (TextView) findViewById(R.id.buy_10qikj_tvfh1);
					TextView buy_10qikj_tvfh2 = (TextView) findViewById(R.id.buy_10qikj_tvfh2);
					TextView buy_10qikj_tvfh3 = (TextView) findViewById(R.id.buy_10qikj_tvfh3);
					TextView buy_10qikj_tvfh4 = (TextView) findViewById(R.id.buy_10qikj_tvfh4);
					TextView buy_10qikj_tvfh5 = (TextView) findViewById(R.id.buy_10qikj_tvfh5);
					TextView buy_10qikj_tvfh6 = (TextView) findViewById(R.id.buy_10qikj_tvfh6);
					TextView buy_10qikj_tvfh7 = (TextView) findViewById(R.id.buy_10qikj_tvfh7);
					TextView buy_10qikj_tvfh8 = (TextView) findViewById(R.id.buy_10qikj_tvfh8);
					TextView buy_10qikj_tvfh9 = (TextView) findViewById(R.id.buy_10qikj_tvfh9);
					TextView buy_10qikj_tvfh10 = (TextView) findViewById(R.id.buy_10qikj_tvfh10);
					buy_10qikj_tvfh1.setVisibility(View.GONE);
					buy_10qikj_tvfh2.setVisibility(View.GONE);
					buy_10qikj_tvfh3.setVisibility(View.GONE);
					buy_10qikj_tvfh4.setVisibility(View.GONE);
					buy_10qikj_tvfh5.setVisibility(View.GONE);
					buy_10qikj_tvfh6.setVisibility(View.GONE);
					buy_10qikj_tvfh7.setVisibility(View.GONE);
					buy_10qikj_tvfh8.setVisibility(View.GONE);
					buy_10qikj_tvfh9.setVisibility(View.GONE);
					buy_10qikj_tvfh10.setVisibility(View.GONE);

					buy_ssq_10qikj_tvblue1.setVisibility(View.GONE);
					buy_ssq_10qikj_tvblue1.setVisibility(View.GONE);
					buy_ssq_10qikj_tvblue2.setVisibility(View.GONE);
					buy_ssq_10qikj_tvblue3.setVisibility(View.GONE);
					buy_ssq_10qikj_tvblue4.setVisibility(View.GONE);
					buy_ssq_10qikj_tvblue5.setVisibility(View.GONE);
					buy_ssq_10qikj_tvblue6.setVisibility(View.GONE);
					buy_ssq_10qikj_tvblue7.setVisibility(View.GONE);
					buy_ssq_10qikj_tvblue8.setVisibility(View.GONE);
					buy_ssq_10qikj_tvblue9.setVisibility(View.GONE);
					buy_ssq_10qikj_tvblue10.setVisibility(View.GONE);
				}
			}
		} else {
			buy_ssqxh_ll10kjdetail.setVisibility(View.GONE);
		}
	}

	// 红球初始化
	public void RedBallInit() {
		red_dintInt = new DynArrayInt();
		imButton01 = (Button) findViewById(R.id.buy_ssqxh_imageButton01);
		imButton01.setSelected(false);
		imButton01.setText("01");
		imButton01.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton01.isSelected()) {
					imButton01.setSelected(false);
					red_dintInt.remove(1);
				} else {
					imButton01.setSelected(true);
					red_dintInt.addInt(1);
				}
				FactoryResult();
			}
		});

		imButton02 = (Button) findViewById(R.id.buy_ssqxh_imageButton02);
		imButton02.setSelected(false);
		imButton02.setText("02");
		imButton02.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton02.isSelected()) {
					imButton02.setSelected(false);
					red_dintInt.remove(2);
				} else {
					imButton02.setSelected(true);
					red_dintInt.addInt(2);
				}

				FactoryResult();
			}
		});

		imButton03 = (Button) findViewById(R.id.buy_ssqxh_imageButton03);
		imButton03.setSelected(false);
		imButton03.setText("03");
		imButton03.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton03.isSelected()) {
					imButton03.setSelected(false);
					red_dintInt.remove(3);

				} else {
					imButton03.setSelected(true);
					red_dintInt.addInt(3);
				}
				FactoryResult();
			}
		});

		imButton04 = (Button) findViewById(R.id.buy_ssqxh_imageButton04);
		imButton04.setSelected(false);
		imButton04.setText("04");
		imButton04.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton04.isSelected()) {
					imButton04.setSelected(false);
					red_dintInt.remove(4);
				} else {
					imButton04.setSelected(true);
					red_dintInt.addInt(4);
				}
				FactoryResult();
			}
		});

		imButton05 = (Button) findViewById(R.id.buy_ssqxh_imageButton05);
		imButton05.setSelected(false);
		imButton05.setText("05");
		imButton05.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton05.isSelected()) {
					imButton05.setSelected(false);
					red_dintInt.remove(5);
				} else {
					imButton05.setSelected(true);
					red_dintInt.addInt(5);
				}
				FactoryResult();
			}
		});

		imButton06 = (Button) findViewById(R.id.buy_ssqxh_imageButton06);
		imButton06.setSelected(false);
		imButton06.setText("06");
		imButton06.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton06.isSelected()) {
					imButton06.setSelected(false);
					red_dintInt.remove(6);
				} else {
					imButton06.setSelected(true);
					red_dintInt.addInt(6);
				}
				FactoryResult();
			}
		});

		imButton07 = (Button) findViewById(R.id.buy_ssqxh_imageButton07);
		imButton07.setSelected(false);
		imButton07.setText("07");
		imButton07.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton07.isSelected()) {
					imButton07.setSelected(false);
					red_dintInt.remove(7);
				} else {
					imButton07.setSelected(true);
					red_dintInt.addInt(7);
				}
				FactoryResult();
			}
		});

		imButton08 = (Button) findViewById(R.id.buy_ssqxh_imageButton08);
		imButton08.setSelected(false);
		imButton08.setText("08");
		imButton08.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton08.isSelected()) {
					imButton08.setSelected(false);
					red_dintInt.remove(8);
				} else {
					imButton08.setSelected(true);
					red_dintInt.addInt(8);
				}
				FactoryResult();
			}
		});

		imButton09 = (Button) findViewById(R.id.buy_ssqxh_imageButton09);
		imButton09.setSelected(false);
		imButton09.setText("09");
		imButton09.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton09.isSelected()) {
					imButton09.setSelected(false);
					red_dintInt.remove(9);
				} else {
					imButton09.setSelected(true);
					red_dintInt.addInt(9);
				}
				FactoryResult();
			}
		});

		imButton10 = (Button) findViewById(R.id.buy_ssqxh_imageButton10);
		imButton10.setSelected(false);
		imButton10.setText("10");
		imButton10.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton10.isSelected()) {
					imButton10.setSelected(false);
					red_dintInt.remove(10);
				} else {
					imButton10.setSelected(true);
					red_dintInt.addInt(10);
				}
				FactoryResult();
			}
		});

		imButton11 = (Button) findViewById(R.id.buy_ssqxh_imageButton11);
		imButton11.setSelected(false);
		imButton11.setText("11");
		imButton11.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton11.isSelected()) {
					imButton11.setSelected(false);
					red_dintInt.remove(11);
				} else {
					imButton11.setSelected(true);
					red_dintInt.addInt(11);
				}
				FactoryResult();
			}
		});

		imButton12 = (Button) findViewById(R.id.buy_ssqxh_imageButton12);
		imButton12.setSelected(false);
		imButton12.setText("12");
		imButton12.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton12.isSelected()) {
					imButton12.setSelected(false);
					red_dintInt.remove(12);
				} else {
					imButton12.setSelected(true);
					red_dintInt.addInt(12);
				}
				FactoryResult();
			}
		});

		imButton13 = (Button) findViewById(R.id.buy_ssqxh_imageButton13);
		imButton13.setSelected(false);
		imButton13.setText("13");
		imButton13.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton13.isSelected()) {
					imButton13.setSelected(false);
					red_dintInt.remove(13);
				} else {
					imButton13.setSelected(true);
					red_dintInt.addInt(13);
				}
				FactoryResult();
			}
		});

		imButton14 = (Button) findViewById(R.id.buy_ssqxh_imageButton14);
		imButton14.setSelected(false);
		imButton14.setText("14");
		imButton14.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton14.isSelected()) {
					imButton14.setSelected(false);
					red_dintInt.remove(14);
				} else {
					imButton14.setSelected(true);
					red_dintInt.addInt(14);
				}
				FactoryResult();
			}
		});
		imButton15 = (Button) findViewById(R.id.buy_ssqxh_imageButton15);
		imButton15.setSelected(false);
		imButton15.setText("15");
		imButton15.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton15.isSelected()) {
					imButton15.setSelected(false);
					red_dintInt.remove(15);
				} else {
					imButton15.setSelected(true);
					red_dintInt.addInt(15);
				}

				FactoryResult();
			}
		});

		imButton16 = (Button) findViewById(R.id.buy_ssqxh_imageButton16);
		imButton16.setSelected(false);
		imButton16.setText("16");
		imButton16.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton16.isSelected()) {
					imButton16.setSelected(false);
					red_dintInt.remove(16);
				} else {
					imButton16.setSelected(true);
					red_dintInt.addInt(16);
				}

				FactoryResult();
			}
		});

		imButton17 = (Button) findViewById(R.id.buy_ssqxh_imageButton17);
		imButton17.setSelected(false);
		imButton17.setText("17");
		imButton17.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton17.isSelected()) {
					imButton17.setSelected(false);
					red_dintInt.remove(17);
				} else {
					imButton17.setSelected(true);
					red_dintInt.addInt(17);
				}
				FactoryResult();
			}
		});

		imButton18 = (Button) findViewById(R.id.buy_ssqxh_imageButton18);
		imButton18.setSelected(false);
		imButton18.setText("18");
		imButton18.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton18.isSelected()) {
					imButton18.setSelected(false);
					red_dintInt.remove(18);
				} else {
					imButton18.setSelected(true);
					red_dintInt.addInt(18);
				}
				FactoryResult();
			}
		});

		imButton19 = (Button) findViewById(R.id.buy_ssqxh_imageButton19);
		imButton19.setSelected(false);
		imButton19.setText("19");
		imButton19.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton19.isSelected()) {
					imButton19.setSelected(false);
					red_dintInt.remove(19);
				} else {
					imButton19.setSelected(true);
					red_dintInt.addInt(19);
				}
				FactoryResult();
			}
		});

		imButton20 = (Button) findViewById(R.id.buy_ssqxh_imageButton20);
		imButton20.setSelected(false);
		imButton20.setText("20");
		imButton20.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton20.isSelected()) {
					imButton20.setSelected(false);
					red_dintInt.remove(20);
				} else {
					imButton20.setSelected(true);
					red_dintInt.addInt(20);
				}
				FactoryResult();
			}
		});

		imButton21 = (Button) findViewById(R.id.buy_ssqxh_imageButton21);
		imButton21.setSelected(false);
		imButton21.setText("21");
		imButton21.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton21.isSelected()) {
					imButton21.setSelected(false);
					red_dintInt.remove(21);
				} else {
					imButton21.setSelected(true);
					red_dintInt.addInt(21);
				}
				FactoryResult();
			}
		});

		imButton22 = (Button) findViewById(R.id.buy_ssqxh_imageButton22);
		imButton22.setSelected(false);
		imButton22.setText("22");
		imButton22.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton22.isSelected()) {
					imButton22.setSelected(false);
					red_dintInt.remove(22);
				} else {
					imButton22.setSelected(true);
					red_dintInt.addInt(22);
				}
				FactoryResult();
			}
		});

		imButton23 = (Button) findViewById(R.id.buy_ssqxh_imageButton23);
		imButton23.setSelected(false);
		imButton23.setText("23");
		imButton23.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton23.isSelected()) {
					imButton23.setSelected(false);
					red_dintInt.remove(23);
				} else {
					imButton23.setSelected(true);
					red_dintInt.addInt(23);
				}
				FactoryResult();
			}
		});

		imButton24 = (Button) findViewById(R.id.buy_ssqxh_imageButton24);
		imButton24.setSelected(false);
		imButton24.setText("24");
		imButton24.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton24.isSelected()) {
					imButton24.setSelected(false);
					red_dintInt.remove(24);
				} else {
					imButton24.setSelected(true);
					red_dintInt.addInt(24);
				}
				FactoryResult();
			}
		});

		imButton25 = (Button) findViewById(R.id.buy_ssqxh_imageButton25);
		imButton25.setSelected(false);
		imButton25.setText("25");
		imButton25.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton25.isSelected()) {
					imButton25.setSelected(false);
					red_dintInt.remove(25);
				} else {
					imButton25.setSelected(true);
					red_dintInt.addInt(25);
				}
				FactoryResult();
			}
		});

		imButton26 = (Button) findViewById(R.id.buy_ssqxh_imageButton26);
		imButton26.setSelected(false);
		imButton26.setText("26");
		imButton26.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton26.isSelected()) {
					imButton26.setSelected(false);
					red_dintInt.remove(26);
				} else {
					imButton26.setSelected(true);
					red_dintInt.addInt(26);
				}
				FactoryResult();
			}
		});

		imButton27 = (Button) findViewById(R.id.buy_ssqxh_imageButton27);
		imButton27.setSelected(false);
		imButton27.setText("27");
		imButton27.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton27.isSelected()) {
					imButton27.setSelected(false);
					red_dintInt.remove(27);

				} else {
					imButton27.setSelected(true);
					red_dintInt.addInt(27);
				}
				FactoryResult();
			}
		});

		imButton28 = (Button) findViewById(R.id.buy_ssqxh_imageButton28);
		imButton28.setSelected(false);
		imButton28.setText("28");
		imButton28.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton28.isSelected()) {
					imButton28.setSelected(false);
					red_dintInt.remove(28);
				} else {
					imButton28.setSelected(true);
					red_dintInt.addInt(28);
				}
				FactoryResult();
			}
		});

		imButton29 = (Button) findViewById(R.id.buy_ssqxh_imageButton29);
		imButton29.setSelected(false);
		imButton29.setText("29");
		imButton29.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton29.isSelected()) {
					imButton29.setSelected(false);
					red_dintInt.remove(29);
				} else {
					imButton29.setSelected(true);
					red_dintInt.addInt(29);
				}
				FactoryResult();
			}
		});

		imButton30 = (Button) findViewById(R.id.buy_ssqxh_imageButton30);
		imButton30.setSelected(false);
		imButton30.setText("30");
		imButton30.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton30.isSelected()) {
					imButton30.setSelected(false);
					red_dintInt.remove(30);
				} else {
					imButton30.setSelected(true);
					red_dintInt.addInt(30);
				}
				FactoryResult();
			}
		});

		imButton31 = (Button) findViewById(R.id.buy_ssqxh_imageButton31);
		imButton31.setSelected(false);
		imButton31.setText("31");
		imButton31.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton31.isSelected()) {
					imButton31.setSelected(false);
					red_dintInt.remove(31);
				} else {
					imButton31.setSelected(true);
					red_dintInt.addInt(31);
				}
				FactoryResult();
			}
		});

		imButton32 = (Button) findViewById(R.id.buy_ssqxh_imageButton32);
		imButton32.setSelected(false);
		imButton32.setText("32");
		imButton32.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton32.isSelected()) {
					imButton32.setSelected(false);
					red_dintInt.remove(32);
				} else {
					imButton32.setSelected(true);
					red_dintInt.addInt(32);
				}
				FactoryResult();
			}
		});

		imButton33 = (Button) findViewById(R.id.buy_ssqxh_imageButton33);
		imButton33.setSelected(false);
		imButton33.setText("33");
		imButton33.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton33.isSelected()) {
					imButton33.setSelected(false);
					red_dintInt.remove(33);
				} else {
					imButton33.setSelected(true);
					red_dintInt.addInt(33);
				}
				FactoryResult();
			}
		});

	}

	// 蓝球初始化
	public void BlueBallInit() {
		blue_dintInt = new DynArrayInt();
		imButton34 = (Button) findViewById(R.id.buy_ssqxh_imageButton34);
		imButton34.setSelected(false);
		imButton34.setText("01");
		imButton34.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton34.isSelected()) {
					imButton34.setSelected(false);
					blue_dintInt.remove(1);
				} else {
					imButton34.setSelected(true);
					blue_dintInt.addInt(1);
				}
				FactoryResult();
			}
		});

		imButton35 = (Button) findViewById(R.id.buy_ssqxh_imageButton35);
		imButton35.setSelected(false);
		imButton35.setText("02");
		imButton35.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton35.isSelected()) {
					imButton35.setSelected(false);
					blue_dintInt.remove(2);
				} else {
					imButton35.setSelected(true);
					blue_dintInt.addInt(2);
				}
				FactoryResult();
			}
		});

		imButton36 = (Button) findViewById(R.id.buy_ssqxh_imageButton36);
		imButton36.setSelected(false);
		imButton36.setText("03");
		imButton36.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton36.isSelected()) {
					imButton36.setSelected(false);
					blue_dintInt.remove(3);
				} else {
					imButton36.setSelected(true);
					blue_dintInt.addInt(3);
				}
				FactoryResult();
			}
		});

		imButton37 = (Button) findViewById(R.id.buy_ssqxh_imageButton37);
		imButton37.setSelected(false);
		imButton37.setText("04");
		imButton37.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton37.isSelected()) {
					imButton37.setSelected(false);
					blue_dintInt.remove(4);
				} else {
					imButton37.setSelected(true);
					blue_dintInt.addInt(4);
				}
				FactoryResult();
			}
		});

		imButton38 = (Button) findViewById(R.id.buy_ssqxh_imageButton38);
		imButton38.setSelected(false);
		imButton38.setText("05");
		imButton38.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton38.isSelected()) {
					imButton38.setSelected(false);
					blue_dintInt.remove(5);
				} else {
					imButton38.setSelected(true);
					blue_dintInt.addInt(5);
				}
				FactoryResult();
			}
		});

		imButton39 = (Button) findViewById(R.id.buy_ssqxh_imageButton39);
		imButton39.setSelected(false);
		imButton39.setText("06");
		imButton39.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton39.isSelected()) {
					imButton39.setSelected(false);
					blue_dintInt.remove(6);
				} else {
					imButton39.setSelected(true);
					blue_dintInt.addInt(6);
				}
				FactoryResult();
			}
		});
		imButton40 = (Button) findViewById(R.id.buy_ssqxh_imageButton40);
		imButton40.setSelected(false);
		imButton40.setText("07");
		imButton40.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton40.isSelected()) {
					imButton40.setSelected(false);
					blue_dintInt.remove(7);
				} else {
					imButton40.setSelected(true);
					blue_dintInt.addInt(7);
				}
				FactoryResult();
			}
		});

		imButton41 = (Button) findViewById(R.id.buy_ssqxh_imageButton41);
		imButton41.setSelected(false);
		imButton41.setText("08");
		imButton41.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton41.isSelected()) {
					imButton41.setSelected(false);
					blue_dintInt.remove(8);
				} else {
					imButton41.setSelected(true);
					blue_dintInt.addInt(8);
				}
				FactoryResult();
			}
		});

		imButton42 = (Button) findViewById(R.id.buy_ssqxh_imageButton42);
		imButton42.setSelected(false);
		imButton42.setText("09");
		imButton42.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton42.isSelected()) {
					imButton42.setSelected(false);
					blue_dintInt.remove(9);
				} else {
					imButton42.setSelected(true);
					blue_dintInt.addInt(9);
				}
				FactoryResult();
			}
		});

		imButton43 = (Button) findViewById(R.id.buy_ssqxh_imageButton43);
		imButton43.setSelected(false);
		imButton43.setText("10");
		imButton43.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton43.isSelected()) {
					imButton43.setSelected(false);
					blue_dintInt.remove(10);
				} else {
					imButton43.setSelected(true);
					blue_dintInt.addInt(10);
				}
				FactoryResult();
			}
		});

		imButton44 = (Button) findViewById(R.id.buy_ssqxh_imageButton44);
		imButton44.setSelected(false);
		imButton44.setText("11");
		imButton44.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton44.isSelected()) {
					imButton44.setSelected(false);
					blue_dintInt.remove(11);
				} else {
					imButton44.setSelected(true);
					blue_dintInt.addInt(11);
				}
				FactoryResult();
			}
		});

		imButton45 = (Button) findViewById(R.id.buy_ssqxh_imageButton45);
		imButton45.setSelected(false);
		imButton45.setText("12");
		imButton45.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton45.isSelected()) {
					imButton45.setSelected(false);
					blue_dintInt.remove(12);
				} else {
					imButton45.setSelected(true);
					blue_dintInt.addInt(12);
				}
				FactoryResult();
			}
		});

		imButton46 = (Button) findViewById(R.id.buy_ssqxh_imageButton46);
		imButton46.setSelected(false);
		imButton46.setText("13");
		imButton46.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton46.isSelected()) {
					imButton46.setSelected(false);
					blue_dintInt.remove(13);
				} else {
					imButton46.setSelected(true);
					blue_dintInt.addInt(13);
				}
				FactoryResult();
			}
		});

		imButton47 = (Button) findViewById(R.id.buy_ssqxh_imageButton47);
		imButton47.setSelected(false);
		imButton47.setText("14");
		imButton47.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton47.isSelected()) {
					imButton47.setSelected(false);
					blue_dintInt.remove(14);
				} else {
					imButton47.setSelected(true);
					blue_dintInt.addInt(14);
				}
				FactoryResult();
			}
		});

		imButton48 = (Button) findViewById(R.id.buy_ssqxh_imageButton48);
		imButton48.setSelected(false);
		imButton48.setText("15");
		imButton48.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton48.isSelected()) {
					imButton48.setSelected(false);
					blue_dintInt.remove(15);
				} else {
					imButton48.setSelected(true);
					blue_dintInt.addInt(15);

				}
				FactoryResult();
			}
		});

		imButton49 = (Button) findViewById(R.id.buy_ssqxh_imageButton49);
		imButton49.setSelected(false);
		imButton49.setText("16");
		imButton49.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imButton49.isSelected()) {
					imButton49.setSelected(false);
					blue_dintInt.remove(16);
				} else {
					imButton49.setSelected(true);
					blue_dintInt.addInt(16);
				}
				FactoryResult();
			}
		});
	}

	// 按个数随机取球

	public int[] RandomGenData(int min, int max, int num, String color) {
		int[] temp;
		Random rndNumber;
		rndNumber = new Random();
		temp = new int[num];
		ArrayList<Integer> a1 = new ArrayList<Integer>();

		for (int i = min; i <= max; i++) {
			a1.add(i);

		}
		for (int i = 0; i < num; i++) {
			int index = rndNumber.nextInt(max - min + 1 - i);
			Object o = a1.get(index);
			temp[i] = ((Integer) o).intValue();
			if (color.equals("red"))
				BallRandom(0, 1, 0, temp[i]);
			if (color.equals("blue"))
				BallRandom(1, 0, 0, temp[i]);
			a1.remove(index);
		}
		Arrays.sort(temp);
		return temp;
	}

	// 并显示
	public void BallRandom(int r, int b, int a, int num) {
		if (num == 1 && r == 0) {
			imButton01.setSelected(true);
		}
		if (num == 2 && r == 0) {
			imButton02.setSelected(true);
		}
		if (num == 3 && r == 0) {
			imButton03.setSelected(true);
		}
		if (num == 4 && r == 0) {
			imButton04.setSelected(true);
		}
		if (num == 5 && r == 0) {
			imButton05.setSelected(true);
		}
		if (num == 6 && r == 0) {
			imButton06.setSelected(true);
		}
		if (num == 7 && r == 0) {
			imButton07.setSelected(true);
		}
		if (num == 8 && r == 0) {
			imButton08.setSelected(true);
		}
		if (num == 9 && r == 0) {
			imButton09.setSelected(true);
		}
		if (num == 10 && r == 0) {
			imButton10.setSelected(true);
		}
		if (num == 11 && r == 0) {
			imButton11.setSelected(true);
		}
		if (num == 12 && r == 0) {
			imButton12.setSelected(true);
		}
		if (num == 13 && r == 0) {
			imButton13.setSelected(true);
		}
		if (num == 14 && r == 0) {
			imButton14.setSelected(true);
		}
		if (num == 15 && r == 0) {
			imButton15.setSelected(true);
		}
		if (num == 16 && r == 0) {
			imButton16.setSelected(true);
		}
		if (num == 17 && r == 0) {
			imButton17.setSelected(true);
		}
		if (num == 18 && r == 0) {
			imButton18.setSelected(true);
		}
		if (num == 19 && r == 0) {
			imButton19.setSelected(true);
		}
		if (num == 20 && r == 0) {
			imButton20.setSelected(true);
		}
		if (num == 21 && r == 0) {
			imButton21.setSelected(true);
		}
		if (num == 22 && r == 0) {
			imButton22.setSelected(true);
		}
		if (num == 23 && r == 0) {
			imButton23.setSelected(true);
		}
		if (num == 24 && r == 0) {
			imButton24.setSelected(true);
		}
		if (num == 25 && r == 0) {
			imButton25.setSelected(true);
		}
		if (num == 26 && r == 0) {
			imButton26.setSelected(true);
		}
		if (num == 27 && r == 0) {
			imButton27.setSelected(true);
		}
		if (num == 28 && r == 0) {
			imButton28.setSelected(true);
		}
		if (num == 29 && r == 0) {
			imButton29.setSelected(true);
		}
		if (num == 30 && r == 0) {
			imButton30.setSelected(true);
		}
		if (num == 31 && r == 0) {
			imButton31.setSelected(true);
		}
		if (num == 32 && r == 0) {
			imButton32.setSelected(true);
		}
		if (num == 33 && r == 0) {
			imButton33.setSelected(true);
		}

		if (num == 1 && b == 0) {
			imButton34.setSelected(true);
		}
		if (num == 2 && b == 0) {
			imButton35.setSelected(true);
		}
		if (num == 3 && b == 0) {
			imButton36.setSelected(true);
		}
		if (num == 4 && b == 0) {
			imButton37.setSelected(true);
		}
		if (num == 5 && b == 0) {
			imButton38.setSelected(true);
		}
		if (num == 6 && b == 0) {
			imButton39.setSelected(true);
		}
		if (num == 7 && b == 0) {
			imButton40.setSelected(true);
		}
		if (num == 8 && b == 0) {
			imButton41.setSelected(true);
		}
		if (num == 9 && b == 0) {
			imButton42.setSelected(true);
		}
		if (num == 10 && b == 0) {
			imButton43.setSelected(true);
		}
		if (num == 11 && b == 0) {
			imButton44.setSelected(true);
		}
		if (num == 12 && b == 0) {
			imButton45.setSelected(true);
		}
		if (num == 13 && b == 0) {
			imButton46.setSelected(true);
		}
		if (num == 14 && b == 0) {
			imButton47.setSelected(true);
		}
		if (num == 15 && b == 0) {
			imButton48.setSelected(true);
		}
		if (num == 16 && b == 0) {
			imButton49.setSelected(true);
		}
	}

	// 随机选号
	public void Random(int red_conut, int blue_conut) {
		RedBallInit();
		BlueBallInit();
		// 随机6个红球和1个蓝球
		red_random = RandomGenData(1, 33, red_conut, "red");
		blue_random = RandomGenData(1, 16, blue_conut, "blue");

		// 随机生成的号码添加到dintInt
		red_dintInt = new DynArrayInt();
		blue_dintInt = new DynArrayInt();

		red_dintInt.addInt(red_random);
		blue_dintInt.addInt(blue_random);

		// 计算注数和金额
		float redball_count = FactoryNum.Ssq_Result(red_dintInt.getSize(), 6) / FactoryNum.Ssq_Result(6, 6);
		float allmoney = redball_count * blue_dintInt.getSize();
		allMoney = (int) (allmoney + 1.0e-6) * 2;
		buy_ssqxh_TextView03.setText((int) (allmoney + 1.0e-6) + "");
		buy_ssqxh_TextView04.setText((int) (allmoney + 1.0e-6) * 2 + "");
		if ((int) (allmoney + 1.0e-6) == 0) {
			buy_ssq_llfoot0.setVisibility(View.VISIBLE);
			buy_ssq_rlfoot1.setVisibility(View.GONE);
		} else {
			buy_ssq_llfoot0.setVisibility(View.GONE);
			buy_ssq_rlfoot1.setVisibility(View.VISIBLE);
		}
	}

	// 计算注数和金额
	public void FactoryResult() {
		// 计算注数和金额
		float redball_count = FactoryNum.Ssq_Result(red_dintInt.getSize(), 6) / FactoryNum.Ssq_Result(6, 6);
		float allmoney = redball_count * blue_dintInt.getSize();
		allMoney = (int) (allmoney + 1.0e-6) * 2;
		buy_ssqxh_TextView03.setText((int) (allmoney + 1.0e-6) + "");
		buy_ssqxh_TextView04.setText((int) (allmoney + 1.0e-6) * 2 + "");
		if ((int) (allmoney + 1.0e-6) == 0) {
			buy_ssq_llfoot0.setVisibility(View.VISIBLE);
			buy_ssq_rlfoot1.setVisibility(View.GONE);
		} else {
			buy_ssq_llfoot0.setVisibility(View.GONE);
			buy_ssq_rlfoot1.setVisibility(View.VISIBLE);
		}
	}

	// 倒计时，时间转化
	private void getCountDown(long end) {
		if (end > 0) {
			String res = "";
			long temp = 0;
			long d = end / 86400;
			temp = end - (d * 86400);
			if (d > 0) {
				res += d + "天";
			}

			long h = temp / 3600;
			temp = temp - (h * 3600);
			if (d >= 0 && h > 0) {
				res += h + "时";
			}

			long m = temp / 60;
			temp = temp - (m * 60);
			if (d >= 0 && h >= 0 && m > 0) {
				res += m + "分";
			}

			long s = temp;
			res += s + "秒";
			buy_ssqxh_TextView02.setText(res);
			// buy_ssqxh_TextView02.setText(endTime+"");
		} else {
			buy_ssqxh_TextView02.setText("----------");

			if (getIssue) {
				getIssue = false;
				AsyncLoader task = new AsyncLoader();
				String[] parms = new String[2];
				parms[0] = "200";
				JSONObject jsob = new JSONObject();
				try {
					// 设置请求所需参数
					jsob.put("LottID", LOT_ID_SSQ);
				} catch (JSONException ex) {
					// TODO Auto-generated catch block
					Log.e("error", ex.toString());
				}
				parms[1] = jsob.toString();
				task.execute(parms);

			}

		}
	}

	Button refres;

	// TitleBar标题栏
	public void TitleBar() {
		// Title信息(返回+Title)
		Button back = (Button) findViewById(R.id.top_title_back);
		back.getBackground().setAlpha(255);// 透明度0~255透明度值 ，值越小越透明
		back.setVisibility(View.VISIBLE);
		back.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				onKeyDown(KeyEvent.KEYCODE_BACK, null);
			}
		});

		TextView info = (TextView) findViewById(R.id.top_title_info);
		info.setText("双色球");// R.string.buy_newssq 双色球-普通

		refres = (Button) findViewById(R.id.top_title_refres);
		// refres.setBackgroundResource(R.color.common_menu);
		refres.setBackgroundDrawable(null);
		refres.setText("帮助");
		refres.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				LayoutInflater inflater = LayoutInflater.from(SsqxhActivity.this);

				// 小目录框的设置
				View menuview = inflater.inflate(R.layout.public_menulink, null);
				m_popupWindow = new PopupWindow(menuview, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

				m_popupWindow.setBackgroundDrawable(new BitmapDrawable());
				m_popupWindow.setOutsideTouchable(true);
				m_popupWindow.showAtLocation(menuview, Gravity.RIGHT | Gravity.TOP, 0, 0);
				m_popupWindow.showAsDropDown(refres);

				menuview.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						m_popupWindow.dismiss();
					}
				});

				Button public_menulink_Button01 = (Button) menuview.findViewById(R.id.public_menulink_Button01);
				public_menulink_Button01.setOnClickListener(new View.OnClickListener() {
					@Override
					public void onClick(View arg0) {
						Intent intent;
						m_popupWindow.dismiss();
						if (checkUserLogin()) {
							Intent intent0 = new Intent();
							intent0.putExtra("lotID", LOT_ID_SSQ);
							intent0.setClass(SsqxhActivity.this, BetRecordActivity.class);
							startActivity(intent0);
						} else {
							intent = new Intent(getApplicationContext(), LoginActivity.class);
							startActivityForResult(intent, REQ_CODE_SSQXH);
						}
					}
				});

				Button public_menulink_Button02 = (Button) menuview.findViewById(R.id.public_menulink_Button02);
				public_menulink_Button02.setOnClickListener(new View.OnClickListener() {
					@Override
					public void onClick(View arg0) {
						Intent intent;
						m_popupWindow.dismiss();
						if (checkUserLogin()) {
							intent = new Intent(getApplicationContext(), ZhRecordActivity.class);
							startActivity(intent);
						} else {
							intent = new Intent(getApplicationContext(), LoginActivity.class);
							startActivityForResult(intent, REQ_CODE_SSQXH);
						}
					}
				});
				Button public_menulink_Button03 = (Button) menuview.findViewById(R.id.public_menulink_Button03);
				public_menulink_Button03.setOnClickListener(new View.OnClickListener() {
					@Override
					public void onClick(View arg0) {
						// TODO Auto-generated method stub
						m_popupWindow.dismiss();
						Intent intent;
						intent = new Intent(getApplicationContext(), KjinfoListByType.class);
						intent.putExtra("LottID", "5");
						intent.putExtra("LottName", getString(R.string.kjinfo_number_s_info02));
						startActivity(intent);
					}
				});
				Button public_menulink_Button04 = (Button) menuview.findViewById(R.id.public_menulink_Button04);
				public_menulink_Button04.setOnClickListener(new View.OnClickListener() {
					@Override
					public void onClick(View arg0) {
						// TODO Auto-generated method stub
						m_popupWindow.dismiss();
						// Intent intent;
						// intent = new Intent(getApplicationContext(),
						// HelpActivity.class);
						// startActivity(intent);
						Intent intent = new Intent(getApplicationContext(), CaiPiaoHelp.class);
						intent.putExtra("cp_title", "双色球");
						intent.putExtra("cp_url", "ssq.html");
						startActivity(intent);
					}
				});
			}
		});
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		// TODO Auto-generated method stub
		if (m_popupWindow != null) {
			m_popupWindow.dismiss();
		}
		return super.onTouchEvent(event);
	}

	public boolean checkUserLogin() {
		// app_balldto = (ApplicationBall) getApplication();
		if (!ApplicationData.getInstance().getLoginName().equals("")
				&& !ApplicationData.getInstance().getLoginPwd().equals("")
				|| !ApplicationData.getInstance().getUserID().equals("")) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			if (m_popupWindow != null) {
				m_popupWindow.dismiss();
			}
			sensor.stop();
			
			if (ifbacklist) {
				Intent intent = new Intent();
				intent.putExtra("list_ssqdto", ApplicationData.getInstance().getList_ssqdto());
				intent.putExtra("AllMoney", ApplicationData.getInstance().getAll_ssqmoney());
				intent.putExtra("LotID", lotID);
				intent.putExtra("IssueID", issueID);
				intent.putExtra("IssueName", issueName);
				intent.setClass(SsqxhActivity.this, SsqxhlbActivity.class);
				SsqxhActivity.this.startActivityForResult(intent, REQ_CODE_BUYMAIN);// (intent);
			} else {
				// 停止监听
				ApplicationData.getInstance().initList();
				if(ifPush){
					Intent intent = new Intent(this, JddMainActivity.class);
			        startActivity(intent);
				}
			}
			this.finish();
			return true;
		} else {
			return super.onKeyDown(keyCode, event);
		}
	};

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.app.Activity#onActivityResult(int, int,
	 * android.content.Intent)
	 */
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		// TODO Auto-generated method stub
		if(resultCode == RESULT_OK) {
			if (requestCode == REQ_CODE_BUYMAIN ) {
				onKeyDown(KeyEvent.KEYCODE_BACK, null);
			} else if(requestCode == REQ_CODE_BUY_LOGIN ) {
				goXhlbSubmit();
			}
		}
	};

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		sensor.stop();
		
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		sensor.start();
		
	}

	@Override
	public void finish() {
		if (m_popupWindow != null) {
			m_popupWindow.dismiss();
		}
		super.finish();
		SysApplication.getInstance().removeActivity(this);
	};

	private List<Map<String, Object>> mData;
	boolean getIssue = true;
	private Map<String, Object> cData;

	class AsyncLoader extends AsyncTask<String, Integer, String> {// 继承AsyncTask

		public AsyncLoader() {
			// TODO Auto-generated constructor stub
			super();
		}

		// 1.准备运行
		protected void onPreExecute() {
		}

		// 2.正在后台运行
		@Override
		protected String doInBackground(String... params) {
			// 处理后台执行的任务，在后台线程执行
			String strResult;
			// 设置请求action
			String action = params[0];
			// 获取请求返回值
			strResult = GetRequestParams.getRequestResult(params[1], action, getApplicationContext());
			return strResult;
		}

		// 3.进度更新
		protected void onProgressUpdate(Integer... progress) {
		}

		// 4.完成后台任务
		protected void onPostExecute(String result) {
			if (result != null) {
				try {
					JSONTokener jsonParser = new JSONTokener(result);
					JSONObject js = (JSONObject) jsonParser.nextValue();
					// 接下来的就是JSON对象的操作了
					if (Integer.parseInt(js.getString("Code")) == 0) {
						mData = getData(result);
						for (int i = 0; i < mData.size(); i++) {
							int id = Integer.parseInt(mData.get(i).get("LotID").toString());
							cData = mData.get(i);
							// Log.v("", "cData= "+cData.toString());
							switch (id) {
							case LOT_ID_SSQ://

								lotID = LOT_ID_SSQ;
								issueID = cData.get("IssueID").toString();
								issueName = cData.get("IssueName").toString();
								endTime = setEndTime(cData);
								strssqEndTime = cData.get("EndTime").toString();// 2014-05-10
																				// 19:00:00
								strssqEndTime = DateUtil.getDateTime4(strssqEndTime);// 2014-05-10
																						// 19:00
								buy_ssqxh_TextView01.setText(issueName);
								getCountDown(endTime);
								break;
							}

						}
					} else {
						Toast.makeText(SsqxhActivity.this, js.getString("Data"), Toast.LENGTH_SHORT).show();
					}
				} catch (JSONException ex) {
					// 异常处理代码
					Log.e("error", ex.toString());
					getIssue = true;
				} finally {
					getIssue = true;
				}
			} else {
			}
		}

		// 5.完成后操作
		protected void onCancelled() {
			getIssue = true;
		}

	}

	public class KJAsyncLoader extends AsyncTask<String, Integer, String> {// 继承AsyncTask

		// 1.准备运行
		protected void onPreExecute() {
			// showdialog.showDialog(KjinfoListByType.this);
		}

		// 2.正在后台运行
		@Override
		protected String doInBackground(String... params) {
			String strResult;
			try {
				// 处理后台执行的任务，在后台线程执行
				JSONObject param = new JSONObject();
				param.put("LottID", params[0]);
				// 设置请求action
				String action = params[1];
				// 获取请求返回值
				strResult = GetRequestParams.getRequestResult(param.toString(), action, getApplicationContext());
				return strResult;
			} catch (Exception e) {
				// TODO: handle exception
				Log.e("error", e.toString());
				return null;
			}
		}

		// 3.进度更新
		protected void onProgressUpdate(Integer... progress) {
		}

		// 4.完成后台任务
		protected void onPostExecute(String result) {
			if (result != null) {
				// Toast.LENGTH_LONG).show();
				try {
					JSONTokener jsonParser = new JSONTokener(result);
					JSONObject js = (JSONObject) jsonParser.nextValue();
					// 接下来的就是JSON对象的操作了
					if (Integer.parseInt(js.getString("Code")) == 0) {
						if (!"".equals(js.getString("Data"))) {
							kjData = getData(result);
							for (int i = 0; i < kjData.size(); i++) {
								String issue = kjData.get(i).get("Issue").toString();
								issue += "期";// "期\t开奖号码"
								kjData.get(i).put("Issue", issue);
								String winNumber = kjData.get(i).get("WinNumber").toString();
								String[] nums = winNumber.split("\\+");
								// mData.get(i).put("Ball", nums[0]);
								kjData.get(i).put("Ball", nums[0].replaceAll(",", " "));
								kjData.get(i).put("BlueBall", nums.length > 1 ? nums[1].trim() : "");
							}
							// Log.v("ssqxh", "kjData= "+kjData.toString());
							// KjInfoListAdapter adapter = new
							// KjInfoListAdapter(KjinfoListByType.this, mData);
							// setListAdapter(adapter);
						} else {
						}
						// showdialog.closeDialog();
					} else {
					}
				} catch (JSONException ex) {
					// 异常处理代码
					Log.e("error", ex.toString());
				} finally {
					// showdialog.closeDialog();
				}
			} else {
			}
		}

		// 5.完成后操作
		protected void onCancelled() {
		}

	}

	private List<Map<String, Object>> getData(String strResult) {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		try {
			JSONTokener jsonParser = new JSONTokener(strResult);
			JSONObject js = (JSONObject) jsonParser.nextValue();
			list = ConvertJsonToList.getList(js.getString("Data"));
		} catch (JSONException ex) {
			// 异常处理代码
			// ex.printStackTrace();
		}

		return list;
	}

	private long setEndTime(Map<String, Object> data) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		long endTime = 0;
		try {
			long a = sdf.parse(data.get("CurrentTime").toString()).getTime();
			long b = sdf.parse(data.get("EndTime").toString()).getTime();
			endTime = (b - a) / 1000;
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			// e.printStackTrace();
		}
		return endTime;
	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		handler.removeCallbacks(runnable);
		super.onDestroy();
	}

	private void editNum() {
		String ssq_ball = ApplicationData.getInstance().getList_ssqdto().get(position).getSsq_ball();
		if (!ssq_ball.equals("")) {
			String[] ballString = ssq_ball.split("-");
			String[] reds = ballString[0].trim().split(" ");
			String[] blues = ballString[1].trim().split(" ");
			String money = ballString[2].trim();
			red_dintInt = new DynArrayInt();
			blue_dintInt = new DynArrayInt();
			allMoney = Integer.valueOf(money);
			for (int i = 0; i < reds.length; i++) {
				BallRandom(0, 1, 0, Integer.valueOf(reds[i]));
				red_dintInt.addInt(Integer.valueOf(reds[i]));
			}
			for (int i = 0; i < blues.length; i++) {
				BallRandom(1, 0, 0, Integer.valueOf(blues[i]));
				blue_dintInt.addInt(Integer.valueOf(blues[i]));
			}
			buy_ssqxh_TextView03.setText((Integer.valueOf(money) / 2) + "");
			buy_ssqxh_TextView04.setText(money);
			buy_ssq_llfoot0.setVisibility(View.GONE);
			buy_ssq_rlfoot1.setVisibility(View.VISIBLE);
		}
	}
}
